<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>三角形定位 </title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width: 200px;
            height: 150px;
            line-height: 150px;
            font-size: 30px;
            text-align: center;
            margin:0 auto;
            background-color: darksalmon;
        }
        .triangle{
            width: 0;
            height: 0;
            display: inline-block;
            border: 15px solid transparent;
            border-top: 15px solid black;
            position: relative;
            top: 7.5px;
        }
        .box:hover .triangle{
            border: 15px solid transparent;
            border-bottom: 15px solid black;
            position: relative;
            top: -7.5px;
        }

        /* 定位里的层级
        z-index表示
        z-index的值越大 层级越大 越靠上（屏幕）显示 
        前提是两个box都要设置position
        否则层级无效*/
        .box1{
            width:200px;
            height: 200px;
            background:cadetblue;
            position:relative;
            top: 20px;
            left: 40px;
            z-index: 1;
        }
        .box2{
            width: 200px;
            height: 200px;
            background: #000;
            position:relative;
            z-index: 2;
        }
    </style>
</head>
<body>
    <div class="box">
        导航
        <span class="triangle"></span>
    </div>
    <div class="box1"></div>
    <div class="box2"></div>
</body>
</html>